#pragma once

#include "Framework/EditorModelSubsystem.h"
#include "Containers/Map.h"
#include "Framework/Tickable.h"
#include "Math/Color.h"
#include "ScriptIntelliSense.m.h"



class RTextDocument;
class REditorScriptFile;
class CEditorScriptNamespace;

//intellisense for engine script
//this class is used to provide Highlighing and AutoCompletion
RCLASS(ExtraHeader= ["Document/TextDocument.h", "Language/EditorScriptFile.h"])
class RScriptIntelliSenseSubsystem : public REditorModelSubsystem , public ITickable
{
    ROBJECT

public:
    RScriptIntelliSenseSubsystem();
    virtual void PostLoadFromAsset()  override;
    
    void Initialize() override;
    void Deinitialize() override;
    RScriptIntelliSenseSubsystem* Get();

    TSharedObjectPtr<REditorScriptFile> FindOrCreateScriptFile(TSharedObjectPtr<RTextDocument> InDocument);

protected:
    RFIELD()
    TMap<TSharedObjectPtr<RTextDocument>, TSharedObjectPtr<REditorScriptFile>> AllScriptFiles;

    void Tick(float DeltaTime) override;

    std::shared_ptr<CEditorScriptNamespace> GlobalNamespace;

    //TVector<CString,TVector<std::weak_ptr<IEditorScriptIdentifier>>> IdentifiersMap;

    SColor UnknowColor=SColor::White;
    SColor CommentColor=SColor::FromHexRGB(0x6A9955);
    SColor NamespaceColor=SColor::FromHexRGB(0x4EC9B0);
    SColor ClassColor=SColor::FromHexRGB(0x4EC9B0);
    SColor FunctionColor=SColor::FromHexRGB(0xDCDCAA);
    SColor FieldColor=SColor::FromHexRGB(0x9CDCFE);
    SColor VariableColor=SColor::FromHexRGB(0x9CDCFE);
    SColor NormalKeywordColor=SColor::FromHexRGB(0x569CD6);
    SColor LiteralStringColor=SColor::FromHexRGB(0xD69D85);
    SColor LiteralNumberColor=SColor::FromHexRGB(0xB5CEA8);
    SColor LiteralBooleanColor=SColor::FromHexRGB(0xB5CEA8);
    SColor DotColor=SColor::White;
    //colors for {} [] ()
    SColor BracketColors[3]=
    {
        SColor::FromHexRGB(0xFFD700),
        SColor::FromHexRGB(0xDA70D6),
        SColor::FromHexRGB(0x179FFF)
    };

};